<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //返回类型
        function type(target) {
            var obj = {
                '[object Object]': 'object',
                '[object Array]': 'array',
                '[object Number]': 'number-object',
                '[object Boolean]': 'boolean-object',
                '[object String]': 'string-object'
            };
            if (target === null) {
                return 'null';
            } else if (typeof(target) == 'object') {
                var str = Object.prototype.toString.call(target);
                return obj[str];
            } else {
                return typeof(target);
            }
        }

        //数组去重  unique--独一无二的 ，只能去重数字数组
        Array.prototype.unique = function () {
            var temp = {},
                arr = [],
                len = this.length;
            for (var i = 0; i < len; i++) {
                if (!temp[this[i]]) {
                    temp[this[i]] = 'abc';
                    arr.push(this[i]);
                }
            }
            return arr;
        }

    </script>
</body>
</html>